#!/bin/bash

SS_MODULE=${SS_MODULE:-"srs"}
REDIS_ADDR=${REDIS_ADDR:-"0.0.0.0"}
REDIS_PORT=${REDIS_PORT:-"10090"}
REDIS_PSWD=${REDIS_PSWD:-"123456"}
SRS_CONF=${SRS_CONF:-"srs.conf"}

while getopts "s:" OPT;
do
    case $OPT in
        s)
            SS_MODULE=$OPTARG
            ;;
        *)
            echo $OPTARG
            ;;
    esac
done


while true;
do
    case $SS_MODULE in
        "app")
            cd /frepai/codes/app/
            python3 app_service.py --host 0.0.0.0 --port 9119 --debug 0 \
                --redis_addr ${REDIS_ADDR} \
                --redis_port ${REDIS_PORT} \
                --redis_passwd ${REDIS_PSWD}
            ;;
        "srs")
            cd /usr/local/srs
            ./objs/srs -c conf/$SRS_CONF.conf
            ;;
        "repnet_tf")
            cd /frepai/codes/app
            python3 zmq/repnet_tf_inference.py \
                --topic zmq.repnet_tf.inference \
                --ckpt /ckpts \
                --out /outputs
            ;;
        *)
            echo "SS_MODULE set error"
            break;;
    esac
    sleep 3
done
